package com.exam.Service;

import com.exam.Entity.Student;
import com.exam.Entity.Teacher;
import com.exam.Mapper.TeacherMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TeacherService {
    @Autowired
    private TeacherMapper teacherMapper;

    public List<Teacher> findTotal(int page, int size) {

        List<Teacher> result = teacherMapper.findAll();

        return result;
    }
    public List<Teacher> findAll(int page, int size) {
        //设置分页参数
        PageHelper.startPage(page, size);
        //执行查询
        List<Teacher> result = teacherMapper.findAll();
        // 包装分页结果
        PageInfo<Teacher> pageInfo = new PageInfo<>(result);

        return pageInfo.getList();
    }


    public List<Teacher> findAll() {
        return teacherMapper.findAll();
    }


    public Teacher findById(Integer teacherId) {
        return teacherMapper.findById(teacherId);
    }


    public int deleteById(Integer teacherId) {
        return teacherMapper.deleteById(teacherId);
    }


    public int update(Teacher teacher) {
        return teacherMapper.update(teacher);
    }


    public int add(Teacher teacher) {
        return teacherMapper.add(teacher);
    }
}
